package com.springcloud.market.pay.service;

import org.springframework.context.annotation.Bean;

import java.util.Map;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UserRegisterMessageHandler {
    @Bean
    public Consumer<Map<String, Object>> userRegisterConsumer() {
        return message -> {
            String userId  = (String) message.get("userId");
            String username = (String) message.get("username");

            log.info("收到用户注册消息，开始处理积分赠送，用户ID：{}，用户名：{}", userId, username);

            // 这里实现你的积分赠送业务逻辑
            try {
                // pointsService.addWelcomePoints(userId);
                log.info("已为用户赠送注册积分，用户ID：{}", userId);
            } catch (Exception e) {
                log.error("赠送积分失败，用户ID：{}", userId, e);
            }
        };
    }
}
